package zk.tool.util;

import org.apache.zookeeper.data.Stat;
import zk.tool.model.TreeItemData;

public class CopyUtil {
    public static enum Type {
        INFO,
        DATA,
        PATH
    }

    public static void copyItemData(Type type, TreeItemData itemData) {
        if (type == null) {
            return;
        }
        if (itemData == null) {
            AlertUtil.info("提示", "请选择节点");
            return;
        }

        switch (type) {
            case DATA:
                String data = itemData.getData();
                if (StringUtil.isBlank(data)) {
                    return;
                }
                SystemUtil.setSystemClipboard(data);
                break;
            case INFO:
                Stat stat = itemData.getStat();
                if (stat == null) {
                    return;
                }
                SystemUtil.setSystemClipboard(StatUtil.formatStatInfo(stat));
                break;
            case PATH:
                String path = itemData.getPath();
                if (StringUtil.isBlank(path)) {
                    return;
                }
                SystemUtil.setSystemClipboard(itemData.getPath());
                break;
            default:
                return;
        }
        AlertUtil.info("提示", "拷贝成功");
    }

}
